using System.ServiceModel;
using System.ServiceModel.Channels;
namespace jSLCore.Client.Presentation.AuthorizeService {
public class jSLAuthorizationServiceBaseSyncedChannel
{
private jSLAuthorizationServiceBaseChannel _asyncChannel;
#region Constructors
        public jSLAuthorizationServiceBaseSyncedChannel(string endpointConfigurationName, EndpointAddress remoteAddress)
        {
            var factory = new ChannelFactory<jSLAuthorizationServiceBaseChannel>(endpointConfigurationName, remoteAddress);
            CreateChannel(factory);
        }

        public jSLAuthorizationServiceBaseSyncedChannel(Binding binding, EndpointAddress rem)
        {
            var factory = new ChannelFactory<jSLAuthorizationServiceBaseChannel>(binding, rem);
            CreateChannel(factory);
        }

        public jSLAuthorizationServiceBaseSyncedChannel(string endpointConfigurationName)
        {
            var factory = new ChannelFactory<jSLAuthorizationServiceBaseChannel>(endpointConfigurationName);
            CreateChannel(factory);
        }

        private void CreateChannel(ChannelFactory<jSLAuthorizationServiceBaseChannel> factory)
        {
            _asyncChannel = factory.CreateChannel();
        }

        #endregion


public System.Guid Authorize(string loginName, string password)
{
var result = _asyncChannel.BeginAuthorize(loginName,password,null,null);
return _asyncChannel.EndAuthorize(result);
}
public void AuthorizeByCode(System.Guid code)
{
var result = _asyncChannel.BeginAuthorizeByCode(code,null,null);
_asyncChannel.EndAuthorizeByCode(result);
}
public void DiagnosticSecurity()
{
var result = _asyncChannel.BeginDiagnosticSecurity(null,null);
_asyncChannel.EndDiagnosticSecurity(result);
}
public int[] GetPermissionSet()
{
var result = _asyncChannel.BeginGetPermissionSet(null,null);
return _asyncChannel.EndGetPermissionSet(result);
}
public jSLCore.Client.Presentation.AuthorizeService.PermissionDescription[] GetInheritedPermissions(System.Guid roleId)
{
var result = _asyncChannel.BeginGetInheritedPermissions(roleId,null,null);
return _asyncChannel.EndGetInheritedPermissions(result);
}
public jSLCore.Client.Presentation.AuthorizeService.PermissionDescription[] GetAllPermissions()
{
var result = _asyncChannel.BeginGetAllPermissions(null,null);
return _asyncChannel.EndGetAllPermissions(result);
}
public void SaveAllPermissions(jSLCore.Client.Presentation.AuthorizeService.PermissionDescription[] permissions)
{
var result = _asyncChannel.BeginSaveAllPermissions(permissions,null,null);
_asyncChannel.EndSaveAllPermissions(result);
}
public jSLCore.Client.Presentation.AuthorizeService.Role GetRole(System.Guid id)
{
var result = _asyncChannel.BeginGetRole(id,null,null);
return _asyncChannel.EndGetRole(result);
}
public jSLCore.Client.Presentation.AuthorizeService.Role[] SearchRoles(string searchText)
{
var result = _asyncChannel.BeginSearchRoles(searchText,null,null);
return _asyncChannel.EndSearchRoles(result);
}
public void CreateRole(string name)
{
var result = _asyncChannel.BeginCreateRole(name,null,null);
_asyncChannel.EndCreateRole(result);
}
public void DeleteRole(System.Guid id)
{
var result = _asyncChannel.BeginDeleteRole(id,null,null);
_asyncChannel.EndDeleteRole(result);
}
public void SaveRole(jSLCore.Client.Presentation.AuthorizeService.Role role)
{
var result = _asyncChannel.BeginSaveRole(role,null,null);
_asyncChannel.EndSaveRole(result);
}
public void ChangeCurrentUserPassword(string oldPwd, string newPwd)
{
var result = _asyncChannel.BeginChangeCurrentUserPassword(oldPwd,newPwd,null,null);
_asyncChannel.EndChangeCurrentUserPassword(result);
}
public jSLCore.Client.Presentation.AuthorizeService.EnumDescription[] GetEnumDescriptions()
{
var result = _asyncChannel.BeginGetEnumDescriptions(null,null);
return _asyncChannel.EndGetEnumDescriptions(result);
}
public jSLCore.Client.Presentation.AuthorizeService.User GetCurrentUser()
{
var result = _asyncChannel.BeginGetCurrentUser(null,null);
return _asyncChannel.EndGetCurrentUser(result);
}
public string GetUserName()
{
var result = _asyncChannel.BeginGetUserName(null,null);
return _asyncChannel.EndGetUserName(result);
}
public void Logout()
{
var result = _asyncChannel.BeginLogout(null,null);
_asyncChannel.EndLogout(result);
}
public void GetAnonymousTicket()
{
var result = _asyncChannel.BeginGetAnonymousTicket(null,null);
_asyncChannel.EndGetAnonymousTicket(result);
}
public bool IsAnonymous()
{
var result = _asyncChannel.BeginIsAnonymous(null,null);
return _asyncChannel.EndIsAnonymous(result);
}

}
}
